// README
//
// There are two steps to adding a property:
//
// 1. Create a member variable to store your property
// 2. Add the get_ and set_ accessors for your property
//
// Remember that both are case sensitive!


/// <reference name="MicrosoftAjaxTimer.debug.js" />
/// <reference name="MicrosoftAjaxWebForms.debug.js" />
/// <reference name="AjaxControlToolkit.ExtenderBase.BaseScripts.js" assembly="AjaxControlToolkit" />


Type.registerNamespace('ScottCateAjax2008.Lesson08.Sample1');

ScottCateAjax2008.Lesson08.Sample1.DisabledButtonBehavior = function(element) {
    ScottCateAjax2008.Lesson08.Sample1.DisabledButtonBehavior.initializeBase(this, [element]);

    // TODO : (Step 1) Add your property variables here
    this._TargetButtonID = null;
    this._DisabledText = null;
}
ScottCateAjax2008.Lesson08.Sample1.DisabledButtonBehavior.prototype = {
    initialize : function() {
        ScottCateAjax2008.Lesson08.Sample1.DisabledButtonBehavior.callBaseMethod(this, 'initialize');
        $addHandler(this.get_element(), 'keyup',Function.createDelegate(this, this._onkeyup));
        this._onkeyup();
    },

    _onkeyup : function() {
        var e = $get(this._TargetButtonID);
        if (e) {
            var disabled = ("" == this.get_element().value);
            e.disabled = disabled;
            if (this._DisabledText) {
                if (disabled) {
                    this._oldValue = e.value;
                    e.value = this._DisabledText;
                } else {
                    if (this._oldValue) {
                        e.value = this._oldValue;
                    }
                }
            }
        }
    },


    dispose : function() {
        ScottCateAjax2008.Lesson08.Sample1.DisabledButtonBehavior.callBaseMethod(this, 'dispose');
    },

    get_TargetButtonID : function() {
        return this._TargetButtonID;
    },
    set_TargetButtonID : function(value) {
        this._TargetButtonID = value;
    },
    
    get_DisabledText : function() {
        return this._DisabledText;
    },
    set_DisabledText : function(value) {
        this._DisabledText = value;
    }
}

ScottCateAjax2008.Lesson08.Sample1.DisabledButtonBehavior.registerClass('ScottCateAjax2008.Lesson08.Sample1.DisabledButtonBehavior', AjaxControlToolkit.BehaviorBase);
